<% prefix = resource_name + titlelize(api.name) -%>
func send<%= prefix -%>Request(d *schema.ResourceData, params<%= api.path_parameter.nil? ? "" : ", context" %> interface{},
    client *golangsdk.ServiceClient) (interface{}, error) {
<% if !api.path_parameter.nil? -%>
    pathParameters := map[string][]string {
<%     api.path_parameter.each do |k, v| -%>
<%=      sprintf("\"%s\": []string{%s},", k, index2navigate(v))  %>
<%     end -%>
    }
    var data = make(map[string]interface{})
    for key, path := range pathParameters {
        value, err := navigateValue(context, path, nil)
        if err != nil {
            return nil, fmt.Errorf("Error retrieving path parameter, err=%s", err)
        }
        data[key] = value
    }
    url, err := replaceVars(d, "<%= api.path -%>", data)
    if err != nil {
        return nil, err
    }
    url = client.ServiceURL(url)
<% elsif api.path.include?("{") -%>
    url, err := replaceVars(d, "<%= api.path -%>", nil)
    if err != nil {
        return nil, err
    }
    url = client.ServiceURL(url)
<% else -%>
    url := client.ServiceURL(<%= sprintf("\"%s\"", api.path) -%>)
<% end -%>

    r := golangsdk.Result{}
    _, r.Err = client.<%= api.verb.capitalize -%>(url, params, <%= api.has_response ? "&r.Body" : "nil" %>, &golangsdk.RequestOpts{
        OkCodes: successHTTPCodes,
        <% unless api.header_params.nil? -%>
        MoreHeaders: map[string]string{
          <% api.header_params.each do |k, v| -%>
            <%= sprintf("\"%s\": \"%s\",", k, v)%>
          <% end -%>
        },
        <% end -%>
    })
    if r.Err != nil {
        return nil, fmt.Errorf("Error running api(<%= api.name -%>), err=%s", r.Err)
    }
    return r.Body, nil
}
